package main

import "fmt"
//1创建一个结构体Employee,设置字段id,name,age,salary，创建几个结构体对象，分别赋值，并打印。
type Employee struct {
	id int //编号
	name string //名字
	age int //年龄
	salary int //薪水
}

func main()  {
	e1:=Employee{id:1,name:"王二狗",age:28,salary:10000}
	print(e1)
	e2:=Employee{2,"李小花",30,5000}
	print(e2)
	e3:=Employee{
		id:3,
		name:"李小龙",
		age:45,
		salary:8000,
	}
	print(e3)

	e4:=Employee{}
	e4.id=4
	e4.name="老王"
	e4.age=22
	e4.salary=20000
	print(e4)

	e5:=new(Employee)
	e5.id=5
	e5.name="老李"
	e5.age=33
	e5.salary=6500
	fmt.Println(e5,*e5)
	print(*e5) //传进去的是一个值类型，不能传指针
	e6:=e5
	fmt.Printf("%T %T\n",e5,e6)
	fmt.Printf("%p %p\n",e5,e6)
	e6.name="老金11"
	fmt.Println(*e6)
	fmt.Println(*e5)

}

func print(p Employee){
	fmt.Printf("%s的编号为：%d,年龄是：%d,工资是：%d\n",p.name,p.id,p.age,p.salary)
}